// // ANCHOR: all
// // ANCHOR: prelude
// use gtk::prelude::*;
// // ANCHOR_END: prelude
// use gtk::{Application, ApplicationWindow, Button};

// pub fn main() {
//     // Create a new application
//     let app = Application::builder()
//         .application_id("org.gtk-rs.example")
//         .build();

//     // Connect to "activate" signal of `app`
//     app.connect_activate(build_ui);

//     // Run the application
//     app.run();
// }

// // ANCHOR: build_ui
// fn build_ui(app: &Application) {
//     // Create a window and set the title
//     let window = ApplicationWindow::builder()
//         .application(app)
//         .title("My GTK App")
//         .build();

//     // ANCHOR: button
//     // Create a button with label and margins
//     let button = Button::builder()
//         .label("Press me!")
//         .margin_top(12)
//         .margin_bottom(12)
//         .margin_start(12)
//         .margin_end(12)
//         .build();

//     // Connect to "clicked" signal of `button`
//     button.connect_clicked(move |button| {
//         // Set the label to "Hello World!" after the button has been clicked on
//         button.set_label("Hello World!");
//     });
//     // ANCHOR_END: button

//     // Add button
//     window.set_child(Some(&button));

//     // Present window to the user
//     window.present();
// }
// // ANCHOR_END: build_ui
// // ANCHOR_END: all
package main

import (
    "fmt"
    "github.com/mattn/go-gtk/glib"
    "github.com/mattn/go-gtk/gtk"
    "os"
)

func main() {
    gtk.Init(&os.Args)

    window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
    window.SetPosition(gtk.WIN_POS_CENTER)
    window.SetTitle("GTK Go!")
    window.SetIconName("gtk-dialog-info")
    window.Connect("destroy", func(ctx *glib.CallbackContext) {
        fmt.Println("got destroy!", ctx.Data().(string))
        gtk.MainQuit()
    }, "foo")

    //--------------------------------------------------------
    // GtkVBox
    vbox := gtk.NewVBox(false, 2)

    //--------------------------------------------------------
    // button
    button := gtk.NewButtonWithLabel("Button with label")
    button.Clicked(func() {
        fmt.Println("button clicked:", button.GetLabel())
        button.SetLabel("Hello World!")
    })
    vbox.Add(button)

    //--------------------------------------------------------
    window.Add(vbox)
    window.SetSizeRequest(600, 600)
    window.ShowAll()
    gtk.Main()
}
